/*
 * global.h
 *
 *  Created on: 2011-5-15
 *      Author: chenl
 */

#ifndef GLOBAL_H_
#define GLOBAL_H_

#include "loki/Singleton.h"
#include "timer/timermgt.h"
#include "logengine/logqueue.h"
#include "logengine/logthread.h"
#include "logengine/buffedlog.h"
#include <ext/pool_allocator.h>

#ifndef LOGLEVEL
	#ifdef DEBUG
		#define LOGLEVEL	enmLogLevel_DEBUG
	#else
		#define LOGLEVEL 	enmLogLevel_INFO
	#endif
#endif

enum
{
	enmTimerType_HeartBeat,
};

enum
{
	enmLogSource_PSThread = 0,
	enmLogSource_UIThread = 1,
};

#define DEFAULT_PS_LOGPREFIX 		"./log/psdemo"

#define DEFAULT_ALLOC				__gnu_cxx::__pool_alloc

typedef Loki::SingletonHolder<CTimerMgt> 	TimerMgt;
#define CREATE_TIMERMGT_INSTANCE 	TimerMgt::Instance
#define GET_TIMERMGT_INSTANCE		TimerMgt::Instance


typedef CLogQueue<3> 							LogQueueType;
typedef Loki::SingletonHolder<LogQueueType> 	LogQueue;
#define CREATE_LOGQUEUE_INSTANCE				LogQueue::Instance
#define GET_LOGQUEUE_INSTANCE					LogQueue::Instance


typedef CLogThread<3> 							LogThread;

typedef CBuffedLog<LogQueueType, enmLogSource_PSThread>	CPSThreadLog;
typedef Loki::SingletonHolder<CPSThreadLog>				PSThreadLog;
#define CREATE_PSTHREADLOG_INSTANCE						PSThreadLog::Instance
#define GET_PSTHREADLOG_INSTANCE						PSThreadLog::Instance

typedef CBuffedLog<LogQueueType, enmLogSource_UIThread>	CUIThreadLog;
typedef Loki::SingletonHolder<CUIThreadLog>				UIThreadLog;
#define CREATE_UITHREADLOG_INSTANCE						UIThreadLog::Instance
#define GET_UITHREADLOG_INSTANCE						UIThreadLog::Instance


#endif /* GLOBAL_H_ */
